#ifndef __LUAFUNCTIONEDITER_H__
#define __LUAFUNCTIONEDITER_H__

#include <QtGui/QDialog>

class QLineEdit;
class QTextEdit;
class QListWidget;
namespace BatchRename
{
	class LuaFunction
	{
	public:
		LuaFunction(void);
		~LuaFunction(void);

	public:
		QString FuncTitle() const;
		void SetFuncTitle(QString title);

		QString FuncScript() const;
		void SetFuncScript(QString script);

		QString FuncDesprition() const;
		void SetFuncDesprition(QString des);

	public:
		void Reset();
		QString Result();

	private:
		QString m_FuncTitle;
		QString m_FuncScript;
		QString m_FuncDespriction;

	private:
		int m_FunctionIndex;
	};

	class LuaFunctionRule
	{
	private:
		LuaFunctionRule(void);
		~LuaFunctionRule(void);

	public:
		static LuaFunctionRule& Single();
		const QVector<LuaFunction*>& ConstLuaFuncKey() const;

	public:
		void SetCurrentFileFullPath(QString name);
		QString CurrentFileFullPath() const;

	private:
		friend class LuaFunction;
		friend class LuaFunctionEditer;
		QVector<LuaFunction*>& LuaFuncKey();
		LuaPerform::LuaState& gLuaState();

	private:
		QString					m_CurrentFileFullPath;
		QVector<LuaFunction*>	m_LuaFuncs;
		LuaPerform::LuaState	m_LuaState;
	};

	class LuaFunctionEditer : public QDialog
	{
		Q_OBJECT
	public:
		LuaFunctionEditer(QWidget* parent);
		~LuaFunctionEditer(void);

	public:
		bool ShowLuaFunctionEditerDlg(int index);

	private slots:
		void MoveOnFunction(bool checked);
		void MoveDownFunction(bool checked);
		void FunctionChanged();
		void Add_Change_Func(bool checked);
		void DelFunc(bool checked);

	private:
		int				m_LastIndex;
		bool			m_HasChanged;
		QListWidget*	m_FuncList;
		QLineEdit*		m_TitleLine;
		QTextEdit*		m_ScriptText;
		QTextEdit*		m_DescriptionText;
		QPushButton*	m_MoveOnFunction;
		QPushButton*	m_MoveDownFunction;
		QPushButton*	m_Add_Change_Function;
		QPushButton*	m_DeleteFunction;
	};
}
#endif